home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Analysis
/
Log Histogram
< prev
next >
Wrap
Text File
|
1995-12-31
|
2KB
|
71 lines
#pragma rtGlobals=1
// Version 1.01, 5/17/94
// Used Wave/D instead of Wave in several places.
// Version 1.10, 12/28/95
// Updated for Igor Pro 3.0. Removed /D which is no longer needed.
// DoLogHist(sw, dwX, dwY, startX, logDeltaX)
// Creates the logarithmic histogram of the source wave by putting
// the appropriate numbers in the destination waves.
// sw is the source wave.
// dwX is the destination x wave.
// dwY is the destination y wave.
// startX, logDeltaX are explained below. See LogHist().
Function DoLogHist(sw, dwX, dwY, startX, logDeltaX)
Wave sw, dwX, dwY
Variable startX, logDeltaX
Variable p, pp, npnts
// first find bin edges and put them in dwX
npnts = numpnts(dwX)
p = 0
do
dwX[p] = startX + 10^(p*logDeltaX)
p += 1
while (p < npnts)
// now find which bin each point of dwY belongs in
npnts = numpnts(sw)
p = 0
do
pp = (log(sw[p]) - startX) / logDeltaX
dwY[pp] += 1
p += 1
while (p < npnts)
End
// LogHist(sourceWave, numBins, startX, logDeltaX)
// Creates XY pair of waves that represent the logarithmic histogram of the source wave.
// If the source wave is named “data” then the output waves will be named “data_hx” and “data_hy”.
// numBins specifies the number of bins in the histogram.
// startX specifies the X coordinate of the left edge of first bin. The bin starts at 10^startX.
// logDeltaX determines the bin width. logDeltaX=1.0 gives you 1 decade/bin.
// Example
// Make/N=100 test = 10^(1+abs(gnoise(3)))
// Display test; ModifyGraph log(left)=1, mode=8,msize=2
// LogHist("test",10,0,1)
// Display test_hy vs test_hx; Modify mode=5, log(bottom)=1
Macro LogHist(sourceWave, numBins, startX, logDeltaX)
String sourceWave
Prompt sourceWave, "Source wave", popup, WaveList("*", ";", "")
Variable numBins = 10
Prompt numBins, "Number of bins in destination wave"
Variable startX = 0
Prompt startX, "Starting X value (first bin starts at 10^startX)"
Variable logDeltaX = 1.0
Prompt logDeltaX, "Log delta X value (1.0 gives 1 decade per bin)"
Silent 1
String destXWave, destYWave
// Concoct names for dest waves.
// This does not work if sourceWave is a full or partial path requiring single quotes (e.g., root:Data:'wave 0').
destXWave = sourceWave + "_hx"
destYWave = sourceWave + "_hy"
Make/O/N=(numBins+1) $destXWave=0, $destYWave=0
DoLogHist($sourceWave, $destXWave, $destYWave, startX, logDeltaX)
End